package com.bravo.mvp.ui.main;


import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.bravo.mvp.R;
import com.bravo.mvp.base.BaseMVPActivity;
import com.bravo.mvp.databinding.ActivityMainBinding;

public class MainActivity extends BaseMVPActivity<MainView, MainPersenter> implements View.OnClickListener, MainView {

    private static final String TAG = MainActivity.class.getSimpleName();
    private ActivityMainBinding mainBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        initEvent();
    }

    private void initEvent() {
        mainBinding.btnChange.setOnClickListener(this);
    }

    @Override
    protected MainPersenter createPersenter() {
        return new MainPersenter();
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_change:
                mActPersenter.doAdd();
                break;
        }
    }

    @Override
    public int getTvNumber() {
        String intStr = mainBinding.tvNumber.getText().toString().trim();
        return Integer.parseInt(intStr);
    }

    @Override
    public void setTvNumber(String s) {
        mainBinding.tvNumber.setText(s);
    }
}
